<?php
    include('./config.php');
    include('./request.php');
    $userid = $result->userid;
    $arr = array();
    try{
        $pdo = new PDO($dsn,$user,$pass);
        $sql = "select * from purchaseorder where user_id = ".$userid;
        $res = $pdo->prepare($sql);
        $res->execute();
        while($rea=$res->fetch(PDO::FETCH_ASSOC)){
            if($rea['accState']=="已收货"){
            $temp = array('goods_id'=>$rea['goods_id'],'goods_name'=>$rea['goods_name'],'goods_price'=>$rea['goods_price'],'market_name'=>$rea['market_name'],'goods_date'=>$rea['order_date'],'goods_sendState'=>$rea['sendState'],'accState'=>$rea['accState'],'accG'=>true,'goods_model'=>$rea['goods_model']);
            array_unshift($arr,$temp);
            }else{
                $temp = array('goods_id'=>$rea['goods_id'],'goods_name'=>$rea['goods_name'],'goods_price'=>$rea['goods_price'],'market_name'=>$rea['market_name'],'goods_date'=>$rea['order_date'],'goods_sendState'=>$rea['sendState'],'accState'=>$rea['accState'],'accG'=>false,'goods_model'=>$rea['goods_model']);
                array_unshift($arr,$temp);
            }
        }
        echo json_encode($arr);
    }catch(PDOException $e){
        echo "服务器出错了";
    }
?>